<template>
  <view class="content">
    <view class="after-info">
      <view class="after-hade" v-if="data.refund.status == 1">
        <view class="after-hade-bt">已退款</view>
      </view>
      <view class="after-hade" v-if="data.refund.status != 1">
        <view class="after-hade-bt" v-if="data.refund.status == 0">退款处理中</view>
        <view class="after-hade-bt" v-if="data.refund.status == -1">已处理</view>
        <text class="after-hade-txt">退款前建议先联系客服，沟通解决退款事宜。申请将达成并退款至你的微信账号，请您耐心等待...</text>
      </view>
      <view class="after-tel">
        <view class="after-tel-left" @click="dianhua">
          <text class="after-tel-left-h4">联系客服</text>
          <text class="after-tel-left-txt">说明情况，协商退款金额</text>
        </view>
      </view>
      <view class="after-jine">
        <view class="after-jine-left">
          <text class="after-tel-left-h4">退款金额</text>
          <text class="after-tel-left-txt"></text>
        </view>
        <view class="after-jine-right">￥{{data.refund.refund_amount}}</view>
      </view>
      <view class="after-shuominbg-box">
        <view class="after-shuominbg-ht">情况说明</view>
        <view class="after-shuominbg-txt">
          <text>{{data.refund.remark}}</text>
        </view>
      </view>
      <view class="distribution-shid" style="margin: 0 auto 30rpx;">
        <view class="distribution-shid-txt">申请时间</view>
        <view class="distribution-shid-sj">
          <text>{{data.refund.create_time}}</text>
        </view>
      </view>
      <view class="distribution-shid" style="margin: 0 auto 30rpx;" v-if="data.refund.status != 0">
        <view class="distribution-shid-txt">审核时间</view>
        <view class="distribution-shid-sj">
          <text>{{data.refund.audit_time}}</text>
        </view>
      </view>
      <view class="after-jine" v-if="data.refund.status != 0">
        <view class="after-jine-left">
          <text class="after-tel-left-h4">实际退款</text>
          <text class="after-tel-left-txt"></text>
        </view>
        <view class="after-jine-right">￥{{data.refund.actual_refund}}</view>
      </view>
      <view class="after-shuominbg-box" v-if="data.refund.status != 0">
        <view class="after-shuominbg-ht">审核说明</view>
        <view class="after-shuominbg-txt">
          <text>{{data.refund.audit_remark}}</text>
        </view>
      </view>
      <button type="default" @click="cexixao" class="chex-btn" v-if="data.refund.status == 0">撤销申请</button>
      <button type="default" @click="shenqing" class="zhx-btn" v-if="data.refund.status == -1">重新申请</button>
    </view>
    <dacizinavtag :current="item_index" @click="tabClick"></dacizinavtag>
  </view>
</template>

<script>
import dacizinavtag from "@/components/dacizi-navtag/dacizi-navtag.vue";
export default {
  components: {
    dacizinavtag
  },
  data() {
    return {
      item_index: 3, // 单页面id
      data: ""
    };
  },
  onLoad(id) {
    var than = this;
    uni.request({
      //获取订单详情
      url: getApp().globalData.http + "/order/info",
      data: {
        id: id.id
      },
      method: "post",
      header: {
        "content-type": "application/x-www-form-urlencoded",
        token: uni.getStorageSync("token")
      },
      success: res => {
        than.data = res.data.data;
      }
    });
  },
  methods: {
    cexixao() {
      uni.request({
        //获取订单详情
        url: getApp().globalData.http + "/order/cancelRefund",
        data: {
          refund_id: this.data.refund.id
        },
        method: "post",
        header: {
          "content-type": "application/x-www-form-urlencoded",
          token: uni.getStorageSync("token")
        },
        success: res => {
          console.log(res);
          if (res.data.code == 1) {
            wx.showToast({
              title: "撤销申请成功",
              icon: "none",
              duration: 2000
            });
            setTimeout(function() {
              wx.navigateBack({
                delta: 1
              });
            }, 1900);
          } else {
            wx.showToast({
              title: res.data.msg,
              icon: "none",
              duration: 2000
            });
          }
        }
      });
    },
    dianhua() {
      console.log(uni.getStorageSync("jyfw"));
      
      wx.makePhoneCall({
        phoneNumber: uni.getStorageSync("jyfw").store_phone
      });
    },
    shenqing() {
      wx.reLaunch({
        url: "/pages/my/after-sales2?id=" + this.data.id
      });
    }
  }
};
</script>
